package polymorphic;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: zhongyisheng
 * Date: 2024-07-03
 * Time: 12:20
 */
public class Test {
    public static void main(String[] args) {
        Animal animal = new Bird("小鸟",10);
        if(animal instanceof Bird){
            Bird bird = (Bird) animal;
            bird.fly();
        }
    }

    public static void func(Animal animal){
        animal.eat();
    }


    public static void main1(String[] args) {
        Dog dog = new Dog("旺财",10);
        func(dog);
        Bird bird = new Bird("小鸟",2);
        func(bird);
    }
}
